<div class="portlet">
  <div class="portlet-header">
    <h1><%=t ".title"%></h1>
  </div>
  <div class="portlet-content">
        <table>
          <tbody>
            <tr>
              <td> <%= label_tag :first_name, t('activerecord.attributes.contact.first_name') %> </td>
              <td> <%=h @contact.first_name %> </td>
            </tr>
            <tr>
              <td> <%= label_tag :last_name, t('activerecord.attributes.contact.last_name') %> </td>
              <td> <%=h @contact.last_name %> </td>
            </tr>
            <tr>
              <td>
                <%= label_tag :sex, t('activerecord.attributes.contact.sex') %><br />
              </td>
              <td>
                <%= h get_sex_label @contact.sex %>
              </td>
            </tr>

            <% if current_user.role?(:role_admin) %>
              <tr>
                <td> <%= label_tag :email, t('activerecord.attributes.contact.email') %> </td>
                <td> <%=h @contact.email %> </td>
              </tr>
            <% end %>
            <tr>
              <td> <%= label_tag :email, t('activerecord.attributes.contact.phone') %> </td>
              <td> <%=h @contact.phone %> </td>
            </tr>
            <tr>
              <td> <%= label_tag :fax, t('activerecord.attributes.contact.fax') %></td>
              <td> <%= h @contact.fax %></td>
            </tr>
            <tr>
              <td> <%= label_tag :email, t('activerecord.attributes.contact.position') %> </td>
              <td> <%=h @contact.position %> </td>
            </tr>

            <% if !@contact.reference.nil? && (@contact.reference_type == 'LibraryDepartment' ||  @contact.reference_type == 'BookshopDepartment' || @contact.reference_type == 'People') %>
              <tr>
                <td> <%= label_tag :email, t('activerecord.attributes.contact.commercial_adress') %> </td>
                <td> <%= h @contact.reference.commercial_adress %> </td>
              </tr>
              <tr>
                <td> <%= label_tag :email, t('activerecord.attributes.contact.postal_adress') %> </td>
                <td> <%= h @contact.reference.postal_adress %> </td>
              </tr
            <% end %>


            <% if current_user.role?(:role_admin) %>
              <tr>
                <td> <%= label_tag :email, t('activerecord.attributes.contact.treatment') %> </td>
                <td> <%=h @contact.treatment.description %> </td>
              </tr>
              <tr>
                <td> <%= label_tag :email, t('activerecord.attributes.contact.regard') %> </td>
                <td> <%=h @contact.regard.description %> </td>
              </tr>
              <tr>
                <td> <%= label_tag :email, t('activerecord.attributes.contact.reference') %> </td>
                <td>
                  <% if !@contact.reference.nil? %>
                    <% if @contact.reference_type == 'People' %>
                      <%= "#{t('activerecord.models.people')} - #{@contact.reference.last_name}, #{@contact.reference.first_name}" %>
                    <% end %>
                    <% if @contact.reference_type == 'Bookshop' %>
                      <%=h "#{t('activerecord.models.bookshop')} - #{@contact.reference.name}" %>
                    <% end %>
                    <% if @contact.reference_type == 'Institute' %>
                      <%=h "#{t('activerecord.models.institute')} - #{@contact.reference.name}" %>
                    <% end %>
                    <% if @contact.reference_type == 'Publisher' %>
                      <%=h "#{t('activerecord.models.publisher')} - #{@contact.reference.name}" %>
                    <% end %>
                  <% end %>
                </td>
              </tr>
              <tr>
                <td>
                  <%= label_tag t('activerecord.attributes.contact.user') %>
                </td>
                <td>
                  <% if !@contact.user.nil? %>
                    <%=h @contact.user.email %>
                  <% end %>
                </td>
              </tr>
            <% end %>
              
            <tr>
              <td>
                <%= label_tag :language, t('activerecord.attributes.contact.language') %><br />
              </td>
              <td>
                <%= h get_language_name @contact.language %>
              </td>
            </tr>
            <tr>
              <td>
                <%= label_tag :mail_format, t('activerecord.attributes.contact.mail_format') %><br />
              </td>
              <td>
                <%= h get_mail_format_label @contact.mail_format %>
              </td>
            </tr>

          </tbody>
        </table>

        <div class="line-links">
          <%= link_to t('btn_edit'), edit_contact_path(@contact) %> | 
          <% if can? :index, Contact %>
            <%= link_to t('btn_back'), contacts_redirect_back_path(contacts_path) %>
          <% else %>
            <%= link_to t('btn_back'), root_url %>
          <% end %>
        </div>

  </div>
  <div class="portlet-footer">
  </div>
</div>


